import { IntersectionType, OmitType, PartialType, PickType } from '@nestjs/swagger'
import { IsOptional, IsPhoneNumber, IsString } from 'class-validator'
import { ListPaginationDto } from '@/shared/types/globalDto.dto'
import { ExpressItem, PlayerUser } from '../entities/player-user.entity'

export class CreatePlayerUserDto extends OmitType(PlayerUser, [
  'playerUserId',
  'expressInfo',
  'createdAt',
  'updatedAt',
]) {}

export class UpdatePlayerUserDto extends PartialType(
  PickType(CreatePlayerUserDto, ['uid', 'inviteCount', 'questionScore', 'maxRoleLevel', 'isReserved']),
) {}

export class FindOnePlayerUserDto extends PartialType(OmitType(PlayerUser, ['createdAt', 'updatedAt'])) {}

export class FindAllPlayerUserDto extends FindOnePlayerUserDto {}

export class ListPagePlayerUserDto extends PartialType(IntersectionType(FindOnePlayerUserDto, ListPaginationDto)) {}

export class WebListPagePlayerUserDto extends ListPagePlayerUserDto {}

export class LoginPlayerUserDto {
  /**
   * 手机号码
   */
  @IsPhoneNumber('CN', { message: '请输入正确的手机号码' })
  phone: string

  /**
   * 验证码
   */
  @IsString({ message: '请输入正确的验证码' })
  code: string
}

export class SendMessageDto {
  /**
   * 手机号码
   */
  @IsPhoneNumber('CN', { message: '请输入正确的手机号码' })
  phone: string
}

export class InviteDto {
  /**
   * 邀请人的 uid
   */
  @IsOptional()
  @IsString()
  inviteUserUid?: string
}

export class ExpressDto extends ExpressItem {}
